package com.srwl.mytx.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.fastjson.JSONArray;
import com.github.florent37.viewanimator.AnimationListener;
import com.github.florent37.viewanimator.ViewAnimator;
import com.srwl.mytx.Constant;
import com.srwl.mytx.Helper;
import com.srwl.mytx.R;
import com.srwl.mytx.RetrofitManager;
import com.srwl.mytx.activity.BaseActivity;
import com.srwl.mytx.domain.Comment;
import com.srwl.mytx.domain.CommonResult;
import com.srwl.mytx.domain.User;
import com.srwl.mytx.service.CommentService;
import com.srwl.mytx.utils.DateUtils;
import com.srwl.mytx.utils.GlideLoadUtils;
import com.srwl.mytx.utils.Utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class CommentAdapter_v1 extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private static final String TAG = "CommentAdapter";
    private static final Object OPEN_CHILD_COMMENT = 0;
    private static final Object CLOSE_CHILD_COMMENT = 1;
    private static final Object REFRESH_CHILD_COMMENT_SIZE = 3;
    private static final Object REFRESH_CHILD_COMMENT_BACKGROUND = 4;
    private Context context;
    private List<Comment> commentList;
    private CommentClickListener commentClickListener;
    private boolean forbiddenItemClick;
    private boolean showFooter;
    private boolean noMoreData;

    public CommentAdapter_v1(Context context, List<Comment> commentList) {
        this.context = context;
        this.commentList = commentList;
    }

    public CommentAdapter_v1(Context context, List<Comment> commentList, CommentClickListener commentClickListener) {
        this.context = context;
        this.commentList = commentList;
        this.commentClickListener = commentClickListener;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType) {
            case Constant.COMMENT_TYPE_NORMAL:
                return new CommentViewHolder(LayoutInflater.from(context).inflate(R.layout.tx_comment_item, parent, false));

            case Constant.COMMENT_TYPE_FOOTER:
                return new FooterViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.comment_list_footer, parent, false));
            case Constant.COMMENT_TYPE_CHILD:
            default:
                return new ChildCommentViewHolder(LayoutInflater.from(context).inflate(R.layout.tx_child_comment_item_v2, parent, false));
        }

    }

    @Override
    public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (commentClickListener != null) {
                    commentClickListener.commentItemLongClick(position);
                    return true;
                } else {
                    return false;
                }
            }
        });
        if (holder instanceof CommentViewHolder) {
            onNormalCommentBindView(holder, position);
        } else if (holder instanceof ChildCommentViewHolder) {
            onChildCommentBindView(holder, position);

        } else {
            FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
            if (noMoreData) {
                footerViewHolder.progressBar.setVisibility(View.GONE);
                footerViewHolder.tvLoadingMsg.setVisibility(View.VISIBLE);
            }
        }
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List<Object> payloads) {
        if (payloads.isEmpty()) {//必须判断，因为是 重写这个3个参数的onBindViewHolder方法，就不会调用两个参数的  onBindViewHolder
            onBindViewHolder(holder, position);
            return;
        }
        final Comment comment = commentList.get(position);
        if (holder instanceof CommentViewHolder) {
            final CommentViewHolder commentViewHolder = (CommentViewHolder) holder;
            for (Object payload : payloads) {

                if (payload == OPEN_CHILD_COMMENT) {
                    commentViewHolder.tv_childCommentSize.setText(Utils.numberFormat(comment.getChildSize()));
                    commentViewHolder.rl_showMoreChildComment.setVisibility(View.VISIBLE);
                    commentViewHolder.tv_moreReply.setText("折叠回复：");
                    //灰色箭头顺时针旋转90°，
                    ViewAnimator.animate(commentViewHolder.iv_arrow).rotation(180).duration(300).onStop(new AnimationListener.Stop() {
                        @Override
                        public void onStop() {
                            commentViewHolder.iv_arrow.setImageResource(R.drawable.tx_arrow_down_blue);
                            commentViewHolder.place_holder.setVisibility(View.INVISIBLE);
                        }
                    }).start();

                } else if (payload == CLOSE_CHILD_COMMENT) {
                    commentViewHolder.tv_moreReply.setText("查看回复：");
                    commentViewHolder.place_holder.setVisibility(View.VISIBLE);
                    ViewAnimator.animate(commentViewHolder.iv_arrow).rotation(0).duration(300).onStop(new AnimationListener.Stop() {
                        @Override
                        public void onStop() {
                            commentViewHolder.iv_arrow.setImageResource(R.drawable.tx_arrow_down);
                        }
                    }).start();
                } else if (payload == REFRESH_CHILD_COMMENT_SIZE) {
                    commentViewHolder.tv_childCommentSize.setText(Utils.numberFormat(comment.getChildSize()));
                }
            }
        } else if (holder instanceof ChildCommentViewHolder) {
            ChildCommentViewHolder childCommentViewHolder = (ChildCommentViewHolder) holder;


            for (Object payload : payloads) {
                if (payload == REFRESH_CHILD_COMMENT_BACKGROUND) {
                    setChildCommentItemBackground(childCommentViewHolder, comment);
                }
            }
        }
    }

    /**
     * 普通评论 （父评论）绑定
     *
     * @param holder
     * @param position
     */
    private void onNormalCommentBindView(RecyclerView.ViewHolder holder, int position) {
        final CommentViewHolder commentViewHolder = (CommentViewHolder) holder;
        final Comment comment = commentList.get(position);
        commentViewHolder.tv_nick.setText(comment.getFromNick());
        commentViewHolder.tv_content.setText(comment.getContent());
        commentViewHolder.tv_create_date.setText(DateUtils.getDateToString(comment.getCreated()));
        setPraiseView(commentViewHolder, comment);
        if (comment.getChildSize() != 0) {
            commentViewHolder.rl_showMoreChildComment.setVisibility(View.VISIBLE);
            commentViewHolder.tv_childCommentSize.setText(Utils.numberFormat(comment.getChildSize()));
            //如果此父评论是转开子评论的状态，就显示绿色朝上的箭头，否则显示朝下黑色箭头
            if (comment.isDisplayChildComments()) {
                commentViewHolder.iv_arrow.setImageResource(R.drawable.tx_arrow_down_blue);
                commentViewHolder.iv_arrow.setRotation(-180);
                commentViewHolder.place_holder.setVisibility(View.INVISIBLE);
            } else {
                commentViewHolder.iv_arrow.setImageResource(R.drawable.tx_arrow_down);
                commentViewHolder.iv_arrow.setRotation(0);
                commentViewHolder.place_holder.setVisibility(View.VISIBLE);
            }

        } else {
            commentViewHolder.rl_showMoreChildComment.setVisibility(View.GONE);
        }
//        RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL).dontAnimate();
//        Glide.with(context).load(comment.getFromAvatar()).apply(options).into(commentViewHolder.iv_avatar);
        GlideLoadUtils.glideLoad(context, comment.getFromAvatar(), commentViewHolder.iv_avatar);

        commentViewHolder.iv_avatar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (commentClickListener != null) {
                    User targetUser = getTargetUser(comment);
                    commentClickListener.avatarClick(targetUser);
                }
            }
        });
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (forbiddenItemClick) {
                    return;
                }
                if (commentClickListener != null) {
                    commentClickListener.commentItemClick(comment, holder.getLayoutPosition());
                }
            }
        });
        commentViewHolder.rl_commentPraise.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //((CommentViewHolder) holder).tv_commentPraiseSize.setText(likeSize+"");
                //因为点赞并不是很重要，所以在点赞之后，直接根据是否点过赞，做出相应的页面相应，并不需要等待服务端响应
                if (commentClickListener != null) {
                    if (comment.isHadPraise()) {
                        comment.setHadPraise(false);
                        comment.setPraiseSize(comment.getPraiseSize() - 1);

                        commentClickListener.removeCommentPraise(comment, position);
                    } else {
                        comment.setHadPraise(true);
                        comment.setPraiseSize(comment.getPraiseSize() + 1);
                        commentClickListener.addCommentPraise(comment, position);
                    }
                    setPraiseView(commentViewHolder, comment);
                }
            }
        });

        commentViewHolder.rl_showMoreChildComment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                if (commentClickListener!=null){
//                    commentClickListener.clearCommentTarget();
//                }

                //折叠评论
                List<Comment> childCommentList = comment.getChildCommentList();
                if (comment.isDisplayChildComments()) {
                    comment.setDisplayChildComments(false);
                    commentList.removeAll(childCommentList);
                    notifyItemChanged(commentViewHolder.getLayoutPosition(), CLOSE_CHILD_COMMENT);
                    Log.i(TAG, "onClick: 子评论的长度  " + childCommentList.size());
                    int startPosition = commentViewHolder.getAdapterPosition() + 1;
                    int endPosition = childCommentList.size();
                    notifyItemRangeRemoved(startPosition, endPosition);
                    return;
                }
                //如果含有子评论的数据，直接展示，如果没有，就去服务端下载数据
                if (childCommentList != null && childCommentList.size() != 0) {
                    displayChildComment(comment);
                } else {
                    loadChildComment(comment);
                }
            }
        });
    }

    /**
     * 子评论绑定
     *
     * @param holder
     * @param position
     */
    private void onChildCommentBindView(RecyclerView.ViewHolder holder, int position) {
        final ChildCommentViewHolder childCommentViewHolder = (ChildCommentViewHolder) holder;
        childCommentViewHolder.childComment = commentList.get(position);
        final Comment childComment = commentList.get(position);
        childCommentViewHolder.tv_nick.setText(childComment.getFromNick());
        childCommentViewHolder.tv_create_date.setText(DateUtils.getDateToString(childComment.getCreated()));
//        childCommentViewHolder.tv_content.setText(childComment.getContent());
       // Glide.with(context).load(childComment.getFromAvatar()).diskCacheStrategy(DiskCacheStrategy.ALL).dontAnimate().into(childCommentViewHolder.iv_avatar);
        GlideLoadUtils.glideLoad(context, childComment.getFromAvatar(), childCommentViewHolder.iv_avatar);

        //2表示是子评论的回复
        if (childComment.getType() == 2) {
//            childCommentViewHolder.ll_replay.setVisibility(View.VISIBLE);
//            childCommentViewHolder.tv_replayNick.setText(childComment.getToNick());
            childCommentViewHolder.tv_content.setText(childCommentReplyFormat(childComment.getToNick(), childComment.getContent()));
        } else {
            childCommentViewHolder.tv_content.setText(childComment.getContent());
        }
        //判断是不是子评论的最后一个，如果是，显示“加载更多评论”
//            if (position==childComment.getParentCommentPosition()+childComment.getParentComment().getChildSize()){
//
//            }

        setChildCommentItemBackground(childCommentViewHolder, childComment);
        childCommentViewHolder.iv_avatar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //跳转到当前子评论用户的主页
                if (commentClickListener != null) {
                    User targetUser = getTargetUser(childComment);
                    commentClickListener.avatarClick(targetUser);
                }
            }
        });

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (forbiddenItemClick) {
                    return;
                }

                if (commentClickListener != null) {
                    User replyUser = new User(childComment.getFromUid());
                    replyUser.setUsername(childComment.getFromNick());
                    replyUser.setAvatar(childComment.getFromAvatar());
                    commentClickListener.childCommentItemClick(childComment.getParentComment(), holder.getLayoutPosition(), replyUser);
                }
            }
        });
    }

    /**
     * 设置子评论的背景
     * 控制是否显示   加载更多
     *
     * @param childCommentViewHolder
     * @param childComment
     */
    private void setChildCommentItemBackground(ChildCommentViewHolder childCommentViewHolder, Comment childComment) {
        final Comment parentComment = childComment.getParentComment();
        if (parentComment == null) {
            return;
        }
        //如果是第一个子评论，设置为 item 背景为 开始 背景
        List<Comment> childCommentList = parentComment.getChildCommentList();
        if (childCommentList == null) {
            return;
        }
        int size = childCommentList.size();
        if (size == 1) {//只有一个
            childCommentViewHolder.rl_childComment.setBackgroundResource(R.drawable.single_child_comment_item_bckground_shape);
            checkHaveMoreChildComment(childCommentViewHolder, parentComment);
        } else if (size != 0 && childComment == childCommentList.get(0)) {//第一个
            childCommentViewHolder.rl_childComment.setBackgroundResource(R.drawable.start_child_comment_item_bckground_shape);
            childCommentViewHolder.ll_loadMore.setVisibility(View.GONE);
        } else if (size != 0 && childComment == childCommentList.get(size - 1)) {//最后一个
            childCommentViewHolder.rl_childComment.setBackgroundResource(R.drawable.end_child_comment_item_bckground_shape);
            //如果还有更多子评论，显示 加载更多的按键，并设置监听
            checkHaveMoreChildComment(childCommentViewHolder, parentComment);
        } else {//中间的
            childCommentViewHolder.ll_loadMore.setVisibility(View.GONE);
            childCommentViewHolder.rl_childComment.setBackgroundResource(R.color.yancy_grey100);
        }
    }

    private void checkHaveMoreChildComment(ChildCommentViewHolder childCommentViewHolder, Comment parentComment) {
        if (parentComment.getChildSize() > parentComment.getChildCommentList().size()) {
            childCommentViewHolder.ll_loadMore.setVisibility(View.VISIBLE);
            childCommentViewHolder.ll_loadMore.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    loadChildComment(parentComment);
                }
            });
        } else {
            childCommentViewHolder.ll_loadMore.setVisibility(View.GONE);
        }
    }

    private void setPraiseView(CommentViewHolder commentViewHolder, Comment comment) {
        if (comment.isHadPraise()) {
            commentViewHolder.iv_commentPraise.setBackgroundResource(R.drawable.tx_good_blue);
        } else {
            commentViewHolder.iv_commentPraise.setBackgroundResource(R.drawable.tx_good_gray);
        }
        if (comment.getPraiseSize() != 0) {
            commentViewHolder.tv_commentPraiseSize.setText(Utils.numberFormat(comment.getPraiseSize()));
        } else {
            commentViewHolder.tv_commentPraiseSize.setText("");


        }
    }

    @NonNull
    private User getTargetUser(Comment comment) {
        User targetUser = new User(comment.getFromUid());
        targetUser.setAvatar(comment.getFromAvatar());
        targetUser.setNick(comment.getFromNick());
        return targetUser;
    }

    @Override
    public int getItemViewType(int position) {
        if (showFooter && position == commentList.size()) {
            return Constant.COMMENT_TYPE_FOOTER;
        } else {
            return commentList.get(position).getType();
        }
    }


    @Override
    public int getItemCount() {
        if (showFooter) {
            return commentList.size() + 1;
        } else {
            return commentList.size();
        }
    }

    /**
     * 下载子评论数据完成
     *
     * @param childComments
     */
    public void loadChildCommentComplete(Comment parentComment, List<Comment> childComments) {
        for (Comment childComment : childComments) {
            childComment.setParentComment(parentComment);
        }
        if (parentComment.getChildCommentList() != null && parentComment.getChildCommentList().size() > 0) {//判断是否有在第一次远程加载子评论之前回复的子评论
            parentComment.getChildCommentList().clear();
            parentComment.addChildCommentList(childComments);
            notifyDataSetChanged();//全局刷新
        } else {
            parentComment.addChildCommentList(childComments);
            displayChildComment(parentComment);
        }
        //通过最后一个子评论的“加载更多”按键的点击事件加载的子评论
        {
            // displayMoreChildComment(position, childComments, parentComment);

        }
    }

    /**
     * 这个方法是用于 远程下载子评论完成后，展示到界面上
     *
     * @param childComments
     * @param parentComment
     */
    private void displayMoreChildComment(Comment parentComment, List<Comment> childComments) {
        for (Comment childComment : childComments) {
            childComment.setParentComment(parentComment);
        }
        int parentCommentPosition = commentList.indexOf(parentComment);
        //之前已经展示出来的子评论数量
        int lastChildSize = parentComment.getChildCommentList().size();
        parentComment.addChildCommentList(childComments);
        //从原来已经展示的子评论后面插入
        commentList.addAll(parentCommentPosition + lastChildSize + 1, childComments);
        if (!parentComment.isDisplayChildComments()) {
            parentComment.setDisplayChildComments(true);
            notifyItemChanged(parentCommentPosition, OPEN_CHILD_COMMENT);
        } else {
            notifyItemChanged(parentCommentPosition + lastChildSize, REFRESH_CHILD_COMMENT_BACKGROUND);//通知之前的最后一条重置背景
        }
        notifyItemRangeInserted(parentCommentPosition + lastChildSize + 1, childComments.size());

    }


    public void addChildCommentComplete_v1(Comment parentComment, Comment childComment) {
        if (parentComment == null) {
            return;
        }
        int position = commentList.indexOf(parentComment);
        if (!parentComment.isDisplayChildComments()) {//如果当前父评论不是展开状态，那就设置为展开状态，并且刷新 父Item
            displayChildComment(parentComment);//展开子评论
        } else {//如果已经展开了父评论
            notifyItemChanged(position, REFRESH_CHILD_COMMENT_SIZE); //局部刷新 父评论的数量
            commentList.add(position + 1, childComment);//在数据集中把子评论插入在父评论后的第一个位置
            notifyItemInserted(position + 1);//插入当前新创建的子评论
            notifyItemChanged(position + 2, REFRESH_CHILD_COMMENT_BACKGROUND);//刷新原本处于第一条位置的子评论的背景
        }
        setForbiddenItemClick(false);
    }


    /**
     * 展示子评论
     *
     * @param parentComment
     */
    private void displayChildComment(Comment parentComment) {

        parentComment.setDisplayChildComments(true);
        int parentCommentPosition = commentList.indexOf(parentComment);
        notifyItemChanged(parentCommentPosition, OPEN_CHILD_COMMENT);
        List<Comment> childCommentList = parentComment.getChildCommentList();
        commentList.addAll(parentCommentPosition + 1, childCommentList);
        int size = childCommentList.size();
        notifyItemRangeInserted(parentCommentPosition + 1, size);
        //notifyItemRangeChanged(position + size + 1, commentList.size() - 2 - position - size);


    }

    private void loadChildComment(final Comment parentComment) {
        if (!Helper.getInstance().isNetworkConnected()) {
            ((BaseActivity) context).showToast_v1(context.getString(R.string.network_anomalies));
            return;
        }
        int size = 5;
        Map<String, Object> info = new HashMap<>();
        info.put("parentId", parentComment.getId());
        List<Comment> childCommentList = parentComment.getChildCommentList();
        info.put("offset", childCommentList == null ? 0 : childCommentList.size());
        info.put("size", 5);

        RetrofitManager.getInstance().createRequest(CommentService.class)
                .getChildComment(info)
                .enqueue(new Callback<CommonResult>() {
                    @Override
                    public void onResponse(Call<CommonResult> call, Response<CommonResult> response) {
                        CommonResult result = response.body();
                        if (!response.isSuccessful() || result == null) {
                            Log.e(TAG, "onResponse: " + response.message());
                            return;
                        }
                        if (result.isError()) {
                            Log.e(TAG, "onResponse: " + result.getMsg());
                            return;
                        }
                        JSONArray jsonObject = (JSONArray) result.getData();
                        Log.i(TAG, "onResponse: 加载子评论完成 ：" + jsonObject.toJSONString());
                        List<Comment> childCommentList = jsonObject.toJavaList(Comment.class);
                        if (childCommentList.size() != 0) {
                            displayMoreChildComment(parentComment, childCommentList);
                        }
                    }

                    @Override
                    public void onFailure(Call<CommonResult> call, Throwable t) {

                    }
                });
    }


    public void showFooter(boolean noMoreData) {
        showFooter = true;
        this.noMoreData = noMoreData;
        //notifyItemInserted(commentList.size());
        notifyDataSetChanged();
    }

    public void hideFooter() {
        showFooter = false;
        notifyItemRemoved(commentList.size());
    }

    public class CommentViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_avatar)
        ImageView iv_avatar;
        @BindView(R.id.tv_nick)
        TextView tv_nick;
        @BindView(R.id.tv_content)
        TextView tv_content;
        @BindView(R.id.rl_show_more_child_comment)
        View rl_showMoreChildComment;
        @BindView(R.id.rl_comment_praise)
        View rl_commentPraise;
        @BindView(R.id.iv_comment_praise)
        ImageView iv_commentPraise;
        @BindView(R.id.tv_comment_praise_size)
        TextView tv_commentPraiseSize;
        @BindView(R.id.tv_child_comment_size)
        TextView tv_childCommentSize;
        @BindView(R.id.tv_more_reply)
        TextView tv_moreReply;
        @BindView(R.id.iv_arrow)
        ImageView iv_arrow;
        @BindView(R.id.rl_comment)
        View rl_comment;
        @BindView(R.id.place_holder)
        View place_holder;
        @BindView(R.id.tv_create_date)
        TextView tv_create_date;

        public CommentViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

    class ChildCommentViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_avatar)
        ImageView iv_avatar;
        @BindView(R.id.tv_nick)
        TextView tv_nick;
        @BindView(R.id.tv_content)
        TextView tv_content;
        //        @BindView(R.id.tv_replay_nick)
//        TextView tv_replayNick;
//        @BindView(R.id.ll_replay)
//        View ll_replay;
//        @BindView(R.id.line_2)
//        View line_2;
        @BindView(R.id.ll_load_more)
        View ll_loadMore;
        @BindView(R.id.rl_child_comment)
        View rl_childComment;
        Comment childComment;
        @BindView(R.id.tv_create_date)
        TextView tv_create_date;

        public ChildCommentViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

    public class FooterViewHolder extends RecyclerView.ViewHolder {

        TextView tvLoadingMsg;
        ProgressBar progressBar;

        FooterViewHolder(View v) {
            super(v);
            initView(v);
        }

        private void initView(View v) {
            progressBar = v.findViewById(R.id.progress_bar);
            tvLoadingMsg = v.findViewById(R.id.tv_loading_msg);
        }
    }

    public void setCommentClickListener(CommentClickListener commentClickListener) {
        this.commentClickListener = commentClickListener;
    }

    /**
     * 子评论内容格式化
     *
     * @param toNick  回复的用户名
     * @param content 回复的内容
     * @return
     */
    private String childCommentReplyFormat(String toNick, String content) {
        String formatNick = toNick.length() > 8 ? toNick.substring(0, 7) + "..." : toNick;

        return "回复  " + formatNick + " : " + content;
        //return new StringBuilder().append("回复  ").append(formatNick).append(" ").append("：").append(content).toString();
    }


    /**
     * 为避免在添加子评论的时候，又点击其他 评论item,的加载子评论，导致TopicDetailsActivity中记录的点击点位 失效，最终导致子评论位置错位
     *
     * @param forbiddenItemClick
     */
    public void setForbiddenItemClick(boolean forbiddenItemClick) {
        this.forbiddenItemClick = forbiddenItemClick;
    }

    public interface CommentClickListener {

        void commentItemLongClick(int position);

        /**
         * 用户头像点击，显示用户详情
         *
         * @param targetUser
         */
        void avatarClick(User targetUser);

        /**
         * 普通评论点击事件
         *
         * @param parentComment
         * @param position
         */
        void commentItemClick(Comment parentComment, int position);

        /**
         * 子评论点击事件
         * 对子评论进行回复，为了让该回复显示在某个评论之下，所以仍然把目标评论选为该组子评论的父评论，
         * 和普通评论的区别，需要携带回复对象的User信息，
         *
         * @param parentComment 父评论
         * @param position      当前点击项的位置索引
         * @param rePlyTarget   回复对象的用户信息
         */
        void childCommentItemClick(Comment parentComment, int position, User rePlyTarget);

        /**
         * 给评论点赞
         *
         * @param targetComment
         * @param position
         */
        void addCommentPraise(Comment targetComment, int position);


        void removeCommentPraise(Comment targetComment, int position);


        void clearCommentTarget();

    }

}
